package com.ddf.norman.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @ClassName: DateUtil.java
 * @Description: 提供与Date相关的方法
 * @author: norman
 * @date:  2020-05-06 15:01
 * @version V1.0
 */
public class DateUtil {
    public static String format(Date date, String template){
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(template);
        return simpleDateFormat.format(date);
    }
    public static Date parse(String date, String template){
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(template);
        Date result = null;
        try {
            result =  simpleDateFormat.parse(date);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return result;
    }

}
